﻿using ApiManage.Core.Repository.MongoDB;
using ApiManage.Models.MongoMappings.Sys;
using Rhonin.Common.Components;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace ApiManage.Service.Mongo.Sys.Impl
{
    [Component(LifeStyle.Singleton)]
    public class SysButtonQueryService : ISysButtonQueryService
    {
        private readonly ISysRepository<SysButton> _sysButtonRepository;
        public SysButtonQueryService(ISysRepository<SysButton> sysButtonRepository)
        {
            _sysButtonRepository = sysButtonRepository;
        }

        public SysButton Get(Expression<Func<SysButton, bool>> where)
        {
            return _sysButtonRepository.GetQuery().FirstOrDefault(where);
        }

        public List<SysButton> GetList(Expression<Func<SysButton, bool>> where)
        {
            return _sysButtonRepository.GetQuery().Where(where).ToList();
        }
    }
}
